<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="myButton">断开连接</button>
    <script type="module">
        import { Socket } from './MyWebsocket.js'
let options = {
    url: 'ws://127.0.0.1:8001',
    isReconnect: true,
    heartTime: 10000,
    reconnectTime: 20000,
    reconnectCount: -1,
    heartMsg:'hello',
    openCb(){
        console.log('连接成功')
    },
    closeCb(){
        console.log('连接断开')  
    },
    errorCb(){
        console.log('连接错误')  
    },
  messageCb: (data) =>{
    console.log(data)
  }
}
let wbSocket = new Socket(options)
console.log(myButton)
myButton.addEventListener('click',()=>{
    wbSocket.destroy()
})
    </script>
</body>
</html>